<?php
include "../../Koneksi/koneksi.php";
$cekJumlah = mysql_query("select count(kodeAspekSikap) 'jumlah' from aspekSikap");
           
$cekKode=mysql_fetch_array($cekJumlah);
$kodeAspekSikap = $cekKode['jumlah']+1;

$sikap1 = $_POST['sikap1'];
$sikap2 = $_POST['sikap2'];
$sikap3 = $_POST['sikap3'];
$sikap4 = $_POST['sikap4'];
$sikap5 = $_POST['sikap5'];
$sikap6 = $_POST['sikap6'];
$sikap7 = $_POST['sikap7'];
$sikap8 = $_POST['sikap8'];
$no = $_POST['no'];
$nama = $_POST['nama'];
$ob1 = $_POST['ob1'];
$ob2 = $_POST['ob2'];
$rerataOB=($ob1+$ob2)/2;
$pd1 = $_POST['pd1'];
$pd2 = $_POST['pd2'];
$rerataPD=($pd1+$pd2)/2;
$pt1 = $_POST['pt1'];
$pt2 = $_POST['pt2'];
$rerataPT=($pt1+$pt2)/2;
$jurnal = $_POST['jurnal'];
$nilaiRaport=($rerataOB*2+$rerataPD+$rerataPT+$jurnal)/5;
$konversi="";

if($nilaiRaport>3.5){
    $konversi="Sangat Baik";
}else if($nilaiRaport>2.5 && $nilaiRaport<=3.5){
    $konversi="Baik";
}else if($nilaiRaport>1.5 && $nilaiRaport<=2.5){
    $konversi="Cukup";
}else{
    $konversi="Kurang";
}
$keterangan="";
$cekkkm = mysql_fetch_array(mysql_query("SELECT kkmSikap FROM gurumapel where kodeGuruMapel='INA_1122'"));
if($nilaiRaport>=$cekkkm['kkmSikap']){
    $keterangan="Tuntas";
}else{
    $keterangan="Tidak Tuntas";
}

$ceknis = mysql_fetch_array(mysql_query("SELECT nis FROM pesertadidik where nama='$nama'"));


//$cek = mysql_fetch_array(mysql_query("SELECT * FROM aspekPengetahuan where pesertadidik='$nama' "
//        . "WHERE g.pendidik=p.nip and g.matapelajaran=m.kodemapel and g.kkmPengetahuan is not null "
//        . "and g.pendidik='1122'"));
//if (($cek['kodeGuruMapel']!=null)) {

    mysql_query("Insert into aspekSikap (kodeaspekSikap, gurumapel, pesertadidik, "
            . "ob1, ob2, rerataOB, pd1, pd2, "
            . "rerataPD, pt1, pt2, rerataPT, jurnal, nilaiRaport, nilaiKonversi, ket"
            . ") value "
            . "($kodeAspekSikap, 'INA_1122', '0123', '$ob1', '$ob2', "
            . "'$rerataOB', '$pd1', '$pd2', '$rerataPD', '$pt1', '$pt2', "
            . "'$rerataPT', '$jurnal', '$nilaiRaport', '$konversi', '$keterangan'"
            . ")");
    

    ?>
    <script>alert("Data berhasil disimpan");
                    document.location.href = "../Form/FormAspekSikap.php"</script>
    <?php

?>